/*=====================================================
 Copyright (C) ETERNAL<iqstar@ms24.hinet.net>
 URL : http://www.et99.net

请仔细阅读以下许可协议。当您使用本软体，您将自动成为本协议的一方并受到本协议的约束。

软体和文档受到台湾及中国大陆著作权法及国际条约的保护。您不得：
a)营利、出租或者出借软体或文档的任何部分。
b)反向工程、分解、反编译或者企图察看软体的源代码作为商业用途。
c)修改或者改变软体，或者与其他程式结合。

许可人保留软体及文档的所有权利和权益。您不能通过本许可协定获得软体的任何所有权和知识产权。
===================================================== */
// 全局变量，分页

var myItemLimit = 500;
var myItemList = [];

//##### hole #####
function hole_view(a, b, c, d, e) {
    p_s_close();
    var i = 0;
    var s2 = "";
    w_c('<form action="wog_act.php" method="post" target="mission" name=f1 >');
    arm_link();
    w_c(left_table1);
    var s1 = a.split(",");
    var temp_id = s1[0];
    w_c('<tr class="head_td"><td colspan="4">' + s1[1] + '(<a href=javascript:parent.hole_make("' + temp_id + '")>打洞</a>)</td></tr>');
    w_c('<tr><td>物攻</td><td>魔攻</td><td>物防</td><td>魔防</td></tr>');
    w_c('<tr><td>' + s1[4] + '</td><td>' + s1[5] + '</td><td>' + s1[2] + '</td><td>' + s1[3] + '</td></tr>');
    w_c('<tr class="head_td"><td colspan="4">请选择要镶嵌的洞</font></td></tr>');
    var hole_count = parseInt(s1[6]);
    if (hole_count > 0) {
        if (c != "") {
            s1 = c.split(";");
            for (i = 0; i < s1.length; i++) {
                var j = i + 1;
                if (s1[i] != "0") {
                    s2 = s1[i].split(",");
                    w_c('<tr><td><input type="radio" name="hole" value="' + j + '">洞' + j + '</td><td colspan="2"><a class=uline onclick=parent.arm_show(event.ctrlKey,"' + s2[1] + '","' + s2[0] + '")>' + s2[1] + '</a></td><td><a href=javascript:parent.hole_remove(\'' + temp_id + ',' + e + ',' + j + '\')>分离</a></td></tr>');
                } else {
                    w_c('<tr><td><input type="radio" name="hole" value="' + j + '">洞' + j + '</td><td colspan="2"></td><td></td></tr>');
                }
            }
        } else {
            for (i = 0; i < hole_count; i++) {
                w_c('<tr><td><input type="radio" name="hole" value="' + (i + 1) + '">洞' + (i + 1) + '</td><td colspan="2"></td><td></td></tr>');
            }
        }
    }
    w_c('<tr><td colspan="4" class=b1><ol><li>分离需要消费一颗分离魔石</li><li>打洞需要消费一颗打孔石</li></ol></td></tr>');
    w_c(temp_table2);
    w_c(right_table1);
    w_c('<tr class="head_td"><td colspan="4">请选择要镶入的魔石</td></tr>');
    if (b != '') {
        s1 = b.split(";");
        vData = d;
        for (i = 0; i < s1.length; i++) {
            s2 = s1[i].split(",");
            w_c('<tr><td><input type="radio" name="stone" value="' + s2[0] + '"></td><td colspan="3"><a class=uline onclick=parent.arm_show(event.ctrlKey,"' + s2[1] + '","' + s2[0] + '")>' + s2[1] + '</a></td></tr>');
        }
        w_c('<tr><td colspan="4"><input type="submit" value="确认镶入"></td></tr>');
    }
    w_c(temp_table2);
    w_c('<input type="hidden" name="f" value="hole">');
    w_c('<input type="hidden" name="act" value="setup">');
    w_c('<input type="hidden" name="temp_id" value="' + temp_id + '">');
    w_c('<input type="hidden" name="temp_id_2" value="' + e + '">');
    w_c('</form>');
    p_c();
};

function hole_remove(a1) {
    w_c(temp_table1);
    w_c('<tr class="head_td"><td></td><td>名称</td><td>效果</td></tr>');
    w_c('<tr><td><input type="radio" name="id" value="1"></td><td>分离魔石LV1</td><td>分离成功率25%，失败时会使魔石粉碎</td></tr>');
    w_c('<tr><td><input type="radio" name="id" value="2"></td><td>分离魔石LV2</td><td>分离成功率25%，失败时魔石不会受到损坏</td></tr>');
    w_c('<tr><td colspan="3"><input type="submit" value="分离" > | <input type="button" value="关闭" onClick="parent.p_s_close();" ></td></tr>');
    w_c('<input type="hidden" name="f" value="hole">');
    w_c('<input type="hidden" name="act" value="remove">');
    w_c('<input type="hidden" name="temp_id" value="' + a1 + '">');
    w_c('<input type="hidden" name="temp_id2" value="">');
    var _t = "document.f101";
    w_c('<tr><td colspan="3">分离魔石可至 <a class="uline" onClick="' + _t + '.f.value=\'shop\';' + _t + '.act.value=\'view\';parent.th_submit(document.f101,1,\'5\')">【道具店购买】</a>或 <a class="uline" onClick="parent.act_click(\'mall\',\'view\')">【加值商城购买】</a></td></tr>');
    w_c(temp_table2);
    show_item_lay();
};

function hole_make(a1) {
    w_c(temp_table1);
    w_c('<tr class="head_td"><td></td><td>名称</td><td>效果</td></tr>');
    w_c('<tr><td><input type="radio" name="id" value="1"></td><td>劣质打孔石</td><td>8%机率打洞成功</td></tr>');
    w_c('<tr><td><input type="radio" name="id" value="2"></td><td>打孔石</td><td>100%打洞成功</td></tr>');
    w_c('<tr><td colspan="3"><input type="submit" value="打洞" > | <input type="button" value="关闭" onClick="parent.p_s_close();" ></td></tr>');
    w_c('<input type="hidden" name="f" value="hole">');
    w_c('<input type="hidden" name="act" value="mh">');
    w_c('<input type="hidden" name="temp_id" value="' + a1 + '">');
    var _t = "document.f101";
    w_c('<tr><td colspan="3">劣质打孔石可至 <a class="uline" onClick="parent.honor_view(null)">【勋章所购买】</a>或 打孔石至<a class="uline" onClick="parent.act_click(\'mall\',\'view\')">【加值商城购买】</a></td></tr>');
    w_c(temp_table2);
    show_item_lay();
};

//#### arm begin ####
function arm_need_status(s1, s2, s3, s4) {
    var temp = "";
    s1 = parseInt(s1);
    s2 = parseInt(s2);
    s3 = parseInt(s3);
    s4 = parseInt(s4);
    if (s1 > 0) {
        temp += " 力:" + s1;
        if (s1 > base_str) {
            temp = noset + temp + buff2;
        }
    }
    if (s3 > 0) {
        temp += " 智:" + s3;
        if (s3 > base_smart) {
            temp = noset + temp + buff2;
        }
    }
    if (s2 > 0) {
        temp += " 敏:" + s2;
        if (s2 > base_agi) {
            temp = noset + temp + buff2;
        }
    }
    if (s4 > 0) {
        temp += " 魅:" + s4;
        if (s4 > base_au) {
            temp = noset + temp + buff2;
        }
    }
    if (temp != "") {
        temp = temp.substring(1, temp.length);
    } else {
        temp = "-------";
    }
    return temp;
};

function arm_view(a, temp_id, b, c1) {
    // temp_id编号 -> 0武器,1头,2身体,3手,4脚,5道具,6道具,7魔石,8勋章,9钥匙,10精练石
    var sum = 0;
    myItemList = a.length ? a.split(";") : [];
    var pages = Math.floor(myItemList.length / myItemLimit);
    if (myItemList.length / myItemLimit > pages) {
        pages++
    }
    var pageLinks = '';
    for (let i = 1; i <= pages; i++) {
        pageLinks += `<a href="javascript:;" id="armPaginationItem${i}" onclick="parent.changeMyItemPage(${pages},'armPaginationItem${i}',${i},${temp_id})" class="arm-pagination-item p-5 ${i === 1 ? 'active' : ''}">${i}</a>`
    }
    var viewHeight = document.getElementById('wog_view').contentWindow.document.getElementById('scrollbar-inner').clientHeight

    w_c('<form action="wog_act.php" method="post" target="mission" name="f1" >');
    arm_link(temp_id);

    // 已装备
    if (b) {
        let s1 = b.split(";");
        let temp_message = '';
        let s2 = [];
        var arm_unsetup = "";
        for (let i = 0; i < s1.length; i++) {
            s2 = s1[i].split(",");
            if (Number(s2[21]) === 11) {
                arm_unsetup = `<a href="javascript:parent.act_click('arm','unsetup','11')">卸下</a>`;
            } else {
                arm_unsetup = `<a href="javascript:parent.act_click('arm','unsetup','${temp_id}')">卸下</a>`;
            }
            temp_message = s2[0] + "," + s2[5] + "," + s2[6] + "," + s2[7] + "," + s2[8] + "," + s2[9] + "," + s2[10] + "," + s2[11] + "," + s2[12] + "," + s2[13] + "," + s2[18] + "," + s2[19] + "," + s2[16] + "," + s2[22];
        }
        w_c('<table class="arm-used"><tr bgcolor="#232323" class="text-center"><td>' + arm_unsetup + '</td><td><font color="#FF0000">E</font> <a class="uline" onmouseover=parent.wog_message_box("' + temp_message + '",1,4,null,event.x||event.pageX,event.y||event.pageY); onmouseout=parent.hidebox(\'wog_message_box\'); onclick="parent.arm_show(event.ctrlKey,\'' + s2[0] + '\',\'' + s2[20] + '\');" target="mission">' + s2[0] + '</a></td><td>物攻：' + bf_c(s2[1]) + '</td><td>魔攻：' + bf_c(s2[2]) + '</td><td>物防：' + bf_c(s2[3]) + '</td><td>魔防：' + bf_c(s2[4]) + '</td><td>属性：' + s_status[s2[17]] + '</td><td>售价：' + s2[16] + '</td></tr></table>');
    }

    w_c(`<div class="overflow-y-auto" style="height:${viewHeight - 180}px;">`)
    w_c('<table id="armList"><thead>');
    if (!a) {
        $.toast({text: '分类下暂无内容', position: 'top-center'})
    }
    if (temp_id != 7) {
        w_c('<tr class="head_td"  style="width:50px"><th style="width:50px">类型</th><th>名称</th><th>物攻</th><th>魔攻</th><th>物防</th><th>魔防</th><th>职业</th><th>属性</th><th>能力限制</th><th>洞数</th><th>售价</th><th style="width: 80px;">(<a class="uline text-prompt" onclick="parent.checkAll(\'item_list[]\');">全选</a>)贩卖</th><th>数量</th><th></th></tr>');
    } else {
        w_c('<tr class="head_td"><th>名称</th><th>物攻</th><th>魔攻</th><th>物防</th><th>魔防</th><th>敏捷</th><th>力量</th><th>生命</th><th>体质</th><th>智力</th><th>魅力</th><th>信仰</th><th>HP</th><th>售价</th><th>贩卖/拍卖</th></tr>');
    }
    w_c('</thead><tbody id="armTbody">')

    // w_c('<tr><td colspan="15" >请选择数量(1-99):<input type="text" name="item_num" size="2" maxlength="2" value="1"></td></tr>');
    w_c('</tbody></table>');
    w_c('</div>');
    w_c('<div id="setupArm"></div>')
    w_c(`<div class="text-white py-10">页码：${pageLinks} <span class="ml-20"> 当前分类内总计：${myItemList.length}</span><span class="ml-10">背包容量：${c1}</span></div>`)
    w_c('<div id="armFooter" class="text-white font-size-16 mt-10 ">')
    w_c('<div class="d-flex align-items-center justify-content-between">')
    // if (temp_id <= 5) {
    //     w_c('<input type="submit" class="brick-btn brick-btn-auction brick-btn-md" value="装备" onclick="parent.mouse_xy(event.x||event.pageX,event.y||event.pageY)" onmouseout=parent.hidebox(\'show_message\');>' + ' <input type="submit"  class="brick-btn brick-btn-sale brick-btn-md" value="转至仓库" onClick="document.f1.act.value=\'depot_add\'"> ');
    // }
    w_c(`<div ><span class="font-size-12">欲转移需输入对方游戏的帐号</span> <input type="text" name="pay_id" size="16">
        <input type="submit" class="brick-btn brick-btn-sale brick-btn-md" value="赠送" onClick="document.f1.act.value='move'"></div>`);
    w_c(`<input type="submit" class="brick-btn brick-btn-auction brick-btn-md"  value="批量贩卖" onClick="document.f1.act.value='sale'">`);
    w_c('</div>');
    w_c('</div>');
    w_c('<input type="hidden" id="armF" name="f" value="arm">');
    w_c('<input type="hidden" id="armAct" name="act" value="setup">');
    w_c('<input type="hidden" id="armTemp_type" name="temp_type" value="' + temp_id + '">');
    w_c(`<input type="hidden" id="armItems" name="items">`)
    w_c(`<input type="hidden" id="armItemNum" name="item_num" value="1">`)
    w_c(`<input type="hidden" name="adds" id="armAdds">`)
    w_c('</form>');
    w_c('<div id="show_message" class="arm-operation-message-box" style="display:none;position: absolute;left:0; top: 0; Z-INDEX: 303;opacity :0.85;filter:alpha(opacity=85);" ></div>');
    p_c();
    console.log(myItemList.length)
    if (myItemList.length) {
        var deepList = JSON.parse(JSON.stringify(myItemList));
        var firstPageData = deepList.slice(0, myItemLimit);
        setTimeout(() => {
            renderMyItemList(firstPageData, temp_id, b)
        }, 0)
    }
};

/**
 * 将标记18*12/18&12/18+12这类ID转换为下划线
 * @param id
 * @returns {*}
 */
function formatItemUniqId(id) {
    console.log(id)
    let curr_id = id;
    if (curr_id.indexOf('&') > 1) {
        curr_id = curr_id.replace('&', '_');
    }
    if (curr_id.indexOf('+') > 1) {
        curr_id = curr_id.replace('+', '_');
    }
    if (curr_id.indexOf('*') > 1) {
        curr_id = curr_id.replace('*', '_');
    }
    if (curr_id.indexOf('#') > 1) {
        curr_id = curr_id.replace('*', '_');
    }
    return curr_id;
}

/**
 * 渲染列表
 * @param list
 * @param temp_id
 * @param b
 */
function renderMyItemList(list, temp_id, b) {
    var deepList = JSON.parse(JSON.stringify(list))
    var doc = document.getElementById('wog_view').contentWindow.document
    var tbody = doc.getElementById('armTbody');
    tbody.innerHTML = '<div class="d-flex align-items-center justify-content-center"><span class="text-white text-center box-border-gold-bg p-10">正在加载，请稍后</span></div>'
    var html = '';
    let s1;
    if (deepList.length) {
        for (var i = 0; i < deepList.length; i++) {
            var hole_setup_string = "0";
            var s2 = deepList[i].split(",");
            console.log(s2[1])
            let curr_id = formatItemUniqId(s2[1]);
            console.log(curr_id)
            if (curr_id.indexOf('*0') > -1) {
                continue;
            }
            var s3 = '';
            var s4 = '';

            if (s2[24] != "0") {
                hole_setup_string = '<a href="javascript:parent.act_click(\'hole\',\'view\',\'' + s2[1] + '\')">' + s2[24] + '</a>';
            }

            var arm_view_color = "";
            if (s2[20] == "1") {
                arm_view_color = "bgcolor=" + nosend;
            }
            if (temp_id != 7) {
                var temp_sale_str = '';
                // if (temp_id < 5) {
                //     temp_sale_str = `<input type="checkbox" onclick="event.stopPropagation()" class="checkbox-sale-item" name="item_list[]" id="item_checkbox_${curr_id}_${i}" value="${s2[1]}">`;
                // } else {
                //     s2[1] = s2[0];
                // }
                temp_sale_str = `<input type="checkbox" onclick="event.stopPropagation()" class="checkbox-sale-item" name="item_list[]" id="item_checkbox_${curr_id}_${i}" value="${s2[1]}">`;
                var temp_message = s2[2] + "," + s2[7] + "," + s2[8] + "," + s2[9] + "," + s2[10] + "," + s2[11] + "," + s2[12] + "," + s2[13] + "," + s2[14] + "," + s2[15] + "," + s2[24] + "," + s2[25] + "," + s2[22] + "," + s2[26];
                if (temp_id == 5 && s2[2].indexOf('*0') < 0) {
                    s3 = s2[2].split("*");
                    s4 = s3[0] + '*' + '<span id="show_message_' + s2[1] + '">' + s3[1] + '</span>';
                } else {
                    s4 = s2[2];
                }
                html += `<tr class="item-row" id="item_tr_${curr_id}_${i}" onclick="parent.trOnClick('${curr_id}','${i}')">
<td class="text-center overflow-hidden">
${i + 1}
<!-- ${s2[27]} -->
<!--<input type="radio" name="adds" style="width: 0;height: 0;position:absolute;left: -20px;top: -20px;" id="item_radio_${curr_id}_${i}" value="${s2[1]}">-->
</td>
<td  ${arm_view_color}><a class="uline" onmouseover=parent.wog_message_box("${temp_message}",1,4,null,event.x||event.pageX,event.y||event.pageY); onmouseout=parent.hidebox('wog_message_box'); onclick="parent.arm_show(event.ctrlKey,${s2[2]},${s2[1]});" target="mission">${s4}</a></td>
<td>${bf_c(s2[3])}</td>
<td>${bf_c(s2[4])}</td>
<td>${bf_c(s2[5])}</td>
<td>${bf_c(s2[6])}</td>
<td>${s2[21]}</td>
<td>${s2[23]}</td>
<td>${arm_need_status(s2[16], s2[17], s2[18], s2[19])}</td>
<td>${hole_setup_string}</td>
<td>${s2[22]}</td>
<td class="text-center">${temp_sale_str}</td>
<td><input type="text" oninput="parent.itemNumberOnchange(this)" id="item_num_row_${curr_id}_${i}" placeholder="数量" value="1" style="width:70px"></td>
<td><input type="button" class="brick-btn brick-btn-auction " value="${(s2[27] | s2[23]) == 6 ? '使用' : '装备'}" onclick="parent.singleAction('${curr_id}',${i},'setup');parent.mouse_xy(event.x||event.pageX,event.y||event.pageY)" onmouseout="parent.hidebox('show_message');"> 
<input type="button"  class="brick-btn brick-btn-sale " value="转仓库" onclick="parent.singleAction('${curr_id}','${i}','depot_add')"></td>
<td><input type="button" class="brick-btn brick-btn-sale"  value="贩卖" onclick="parent.singleAction('${curr_id}','${i}','sale')">
<button type="button" class="brick-btn brick-btn-auction"  onclick="parent.f.forms.f1.item_num=document.getElementById('item_num_row_${curr_id}_${i}').value;parent.sale_item('${s2[1]},${s2[2]}',document.getElementById('item_num_row_${curr_id}_${i}').value)">拍卖</button>
</td>
</tr>`;
            } else {
                if (s2[13] == "1") {
                    arm_view_color = "bgcolor=" + nosend;
                }
                html += '<tr  class="item-row"><td> <input type="radio" name="adds" value="' + s2[0] + '"></td><td ' + arm_view_color + '>' + s2[14] + '</td><td>' + s2[1] + '</td><td>' + s2[2] + '</td><td>' + s2[3] + '</td><td>' + s2[4] + '</td><td>' + s2[5] + '</td><td>' + s2[6] + '</td><td>' + s2[7] + '</td><td>' + s2[8] + '</td><td>' + s2[9] + '</td><td>' + s2[10] + '</td><td>' + s2[11] + '</td><td>' + s2[16] + '</td><td>' + s2[15] + '</td><td><input type="radio" name="items" value="' + s2[0] + ',' + s2[14] + '"></td></tr>';
            }
        }

    }
    tbody.innerHTML = html
}

/**
 * 文本框输入失去焦点后s
 * @param e
 */
function itemNumberOnchange(e) {
    var d = document.getElementById('wog_view').contentWindow.document;
    d.getElementById('armItemNum').value = e.value;
}

/**
 * 改变页码
 * @param totalPages
 * @param currId
 * @param page
 * @param temp_id
 */
function changeMyItemPage(totalPages, currId, page, temp_id) {
    var d = document.getElementById('wog_view').contentWindow.document;
    var pageEl = d.getElementsByClassName('arm-pagination-item');
    var defaultClass = '';
    for (let i = 0; i < pageEl.length; i++) {
        let class_name = pageEl[i].className
        if (class_name.indexOf('active') < 0) {
            defaultClass = class_name;
        }
        if (pageEl[i].id === currId) {
            pageEl[i].setAttribute('class', 'arm-pagination-item p-5 active');
        } else {
            pageEl[i].setAttribute('class', 'arm-pagination-item p-5');
        }
    }
    var list = JSON.parse(JSON.stringify(myItemList))
    console.log(list.length)
    var currList = [];
    if (page === totalPages) {
        console.log((page - 1) * myItemLimit - myItemList.length)
        currList = list.slice((page - 1) * myItemLimit - myItemList.length);
    } else {
        currList = list.slice(page * myItemLimit, page * myItemLimit + myItemLimit);
    }
    parent.renderMyItemList(currList, temp_id)
}

/**
 * 如果有radio，就选中
 */
function trOnClick(id, index) {
    console.log(id, index)
    const tr_id = `item_tr_${id}_${index}`
    const checkbox_id = `item_checkbox_${id}_${index}`
    console.log(tr_id)
    console.log(checkbox_id)
    const iframeDoc = document.getElementById('wog_view').contentWindow.document
    let rows = iframeDoc.getElementsByClassName('item-row');
    for (const row of rows) {
        if (row.id !== tr_id) {
            row.setAttribute('class', row.className.replace('bg-primary', ''));
        } else {
            row.setAttribute('class', row.className + ' bg-primary');
        }
    }
    let checkbox_sale_item = iframeDoc.getElementsByClassName('checkbox-sale-item');
    for (const item of checkbox_sale_item) {
        if (item.id !== checkbox_id) {
            item.removeAttribute('checked')
        } else {
            item.setAttribute('checked', 'checked')
        }
    }
    iframeDoc.getElementById('armAdds').value = iframeDoc.getElementById(checkbox_id).value;
    iframeDoc.getElementById('armItemNum').value = iframeDoc.getElementById(`item_num_row_${id}_${index}`).value;
}

/**
 * 设置售卖选中
 * @param id
 * @param index
 * @param act
 */
function singleAction(id, index, act) {
    console.log(id, index, act)
    const iframeDoc = document.getElementById('wog_view').contentWindow.document
    const row_num_id = `item_num_row_${id}_${index}`;
    const row_checkbox_id = `item_checkbox_${id}_${index}`;
    iframeDoc.getElementById('armItemNum').value = iframeDoc.getElementById(row_num_id).value;
    iframeDoc.getElementById('armItems').value = iframeDoc.getElementById(row_checkbox_id).value;

    iframeDoc.getElementById(row_checkbox_id).setAttribute('checked', 'checked');
    f.getElementById('armAct').value = act;
    setTimeout(() => {
        iframeDoc.f1.submit();
    }, 10);
}

function arm_use(a1) {
    var temp = '<table bgcolor=#000000><tr><td>技能熟练度提升' + a1 + '</td></tr></table>';
    f.getElementById("show_message").innerHTML = temp;
    set_div_x_y(UI.mouse_x + 15, UI.mouse_y - 20, "show_message");
};

/**
 * 装备展示
 * @param a1
 * @param a2
 * @param a3
 */
function arm_show(a1, a2, a3) {
    console.log('a1:', a1);
    console.log('a2:', a2);
    console.log('a3:', a3);
    if (a1) {
        set_arm_tochat(a2, a3);
    } else {
        act_click("shop", "check_item", a3);
    }
}

/**
 * 装备穿戴
 * @param a
 * @param b
 * @param b1
 */
function arm_setup(a, b, b1) {
    var temp = '<a class=uline onclick=parent.arm_show(event.ctrlKey,"' + b + '","' + b1 + '")>' + b + '</a>';
    switch (a) {
        case "a_id":
            d_a_name = temp;
            return;
            break;
        case "d_head_id":
            d_head_name = temp;
            return;
            break;
        case "d_body_id":
            d_body_name = temp;
            return;
            break;
        case "d_hand_id":
            d_hand_name = temp;
            return;
            break;
        case "d_foot_id":
            d_foot_name = temp;
            return;
            break;
        case "d_item_id":
            d_item_name = temp;
            return;
            break;
        case "d_item_id2":
            d_item2_name = temp;
            return;
            break;
    }
    return;
};

function depot_list(a, b, a1) {
    w_c(temp_table1 + bank_depot_menu + temp_table2);
    w_c('<form action="wog_act.php" method="post" target="mission">');
    w_c(temp_table1);
    w_c('<tr class="head_td"><td>物品名称</td><td>物品名称</td><td>物品名称</td></tr>');
    if (a != "") {
        var s1 = a.split(";");
        for (var i = 0; i < s1.length; i++) {
            var s2 = s1[i].split(",");
            var arm_view_color = "";
            if (s2[3] == "1") {
                arm_view_color = "bgcolor=" + nosend;
            }
            if ((i + 1) % 3 == 1) {
                w_c('<tr>');
            }
            w_c('<td ' + arm_view_color + '><input type="radio" name="id" value="' + s2[4] + '" > <a class=uline onclick=parent.arm_show(event.ctrlKey,"' + s2[1] + '","' + s2[0] + '")>' + s2[1] + '</a>*<span id="show_message_' + s2[0] + '">' + s2[2] + '</span></td>');
            if ((i + 1) % 3 == 0) {
                w_c('</tr>');
            }
        }
        w_c('<tr><td colspan="9" >帐号:<input type="text" name="pay_id" size="10" value="' + p_name + '"> , ');
        w_c('请选择数量(1-99):<input type="text" name="d_num" size="2" maxlength="2" value="1">');
        w_c(' <input id="depot_btn" type="button" value="转移" onClick="parent.foot_turn(\'arm\',\'depot_move\',this.form.pay_id.value,this.form.d_num.value,this.form.id);parent.btn_disabled(\'depot_btn\');" > (' + a1 + ')</td></tr>');
    }
    w_c('<tr><td colspan="9" class=b1><ol><li>武器防具类限制1次只能转移1个</li></ol></td></tr>');
    w_c('<tr ><td colspan="9" ><div id="show_message"></div></td></tr>');
    w_c(temp_table2);
    w_c('</form>');
    p_c();
};

//##########----------syn_system_start----------##########
function syn_end(s, end) {
    w_c(temp_table1);
    w_c('<tr><td>在合成的途中合成炉突然发出闪闪的白光！<BR><p align=center><font size=7><b>轰隆隆隆隆隆隆隆隆隆隆！</b></p></font>');
    var timerID = setTimeout('syn_end_view("' + s + '","' + end + '")', 1000);
    w_c('</td></tr>' + temp_table2 + "<br>");
    p_c();
};

function syn_end_view(s, end) {
    w_c(temp_table1 + '<tr><td>');
    if (end == 1)//合成成功
    {
        w_c('你的眼前出现了一个闪闪发亮的物品，这次的合成似乎是成功了！<br><br>合成结果： <font color=#ffffaf>' + s + '</font> 入手！');
    }
    if (end == 2)//编号错误
    {
        w_c('你合出了一团无法辨识的东西，或许是一团垃圾....');
    }
    if (end == 3)//合成失败
    {
        w_c('你的眼前出现了一团灰烬....。');
    }
    if (end == 4)//装备过多
    {
        w_c('装备栏已满，无法进行合成。');
    }
    w_c('</td></tr>' + temp_table2);
    p_nc();
};

function syn_link() {
    w_c(temp_table1);
    w_c('<tr><td colspan="13"><a href=javascript:parent.sel_type("0");>武器</a> <a href=javascript:parent.sel_type("1");>头部</a>  <a href=javascript:parent.sel_type("2");>身体</a> <a href=javascript:parent.sel_type("3");>手套</a> <a href=javascript:parent.sel_type("4");>鞋子</a> <a href=javascript:parent.sel_type("5");>道具</a>  <a href=javascript:parent.sel_type("99");>任务品</a> <a href=javascript:parent.sel_type("7");>魔石</a></td></tr>');
    w_c(temp_table2);
    w_c("<br>");
    //p_nc();
};

function syn_view_special(syntotal, page, s, type) {
    w_c('<form action="wog_act.php" method="post" name="pageform" target="mission">');
    pagesplit(syntotal, page);
    w_c('<input type="hidden" name="page" value="1">');
    w_c('<input type="hidden" name="type" value="' + type + '">');
    w_c('<input type="hidden" name="f" value="syn">');
    w_c('<input type="hidden" name="act" value="list">');
    w_c('</form>');
    w_c('<form action="wog_act.php" method="post" target="mission" name=f1>');
    syn_link();
    w_c('<table id="synList">');
    w_c('<tr><td colspan="15" class=b1>我是合成大师,专门替冒险者合成一般商店没有贩卖的物品,我的合成是要收费的,每样物品手续费1000元,但是先提醒合成是有风险的。我的师父爱德华是传说中的合成天才,能合成稀有物品,目前他四处云游冒险,有缘您会遇到他。</td></tr>');
    if (type != 7) {
        w_c('<tr class="head_td"><td></td><td>名称</td><td>物攻</td><td>魔攻</td><td>物防</td><td>魔防</td><td>职业</td><td>属性</td><td>能力限制</td><td>成功率</td></tr>');
    } else {
        w_c('<tr class="head_td"><td></td><td>名称</td><td>物攻</td><td>魔攻</td><td>物防</td><td>魔防</td><td>敏捷</td><td>力量</td><td>生命</td><td>体质</td><td>智力</td><td>魅力</td><td>信仰</td><td>HP</td><td>成功率</td></tr>');
    }
    if (s != "") {
        var s1 = s.split(";");
        for (var i = 0; i < s1.length; i++) {
            var s2 = s1[i].split(",");
            var arm_view_color = "";
            if (s2[12] == "1") {
                arm_view_color = "bgcolor=" + nosend;
            }
            if (type != 7) {
                w_c('<tr><td><input type="radio" name="syn_id" value="' + s2[9] + '"></td><td ' + arm_view_color + '><a href="javascript:parent.act_click(\'syn\',\'detail\',' + s2[9] + ')">' + s2[0] + '</a></td><td>' + s2[1] + '</td><td>' + s2[2] + '</td><td>' + s2[3] + '</td><td>' + s2[4] + '</td><td>' + s2[10] + '</td><td>' + s_status[s2[11]] + '</td><td>' + arm_need_status(s2[5], s2[6], s2[7], s2[8]) + '</td><td>' + s2[13] + '%</td></tr>');
            } else {
                w_c('<tr><td><input type="radio" name="syn_id" value="' + s2[12] + '"></td><td ' + arm_view_color + '><a href="javascript:parent.act_click(\'syn\',\'detail\',' + s2[12] + ')">' + s2[0] + '</a></td><td>' + s2[1] + '</td><td>' + s2[2] + '</td><td>' + s2[3] + '</td><td>' + s2[4] + '</td><td>' + s2[5] + '</td><td>' + s2[6] + '</td><td>' + s2[7] + '</td><td>' + s2[8] + '</td><td>' + s2[9] + '</td><td>' + s2[10] + '</td><td>' + s2[11] + '</td><td>' + s2[15] + '</td><td>' + s2[14] + '%</td></tr>');
            }
        }
    }
    w_c('<tr><td colspan="15">数量:<input type="text" value="1" size="5" maxlength="5" name="item_num"> → <input type="submit" value="确定合成"></td></tr>');
    w_c(temp_table2);
    w_c('<input type="hidden" name="f" value="syn">');
    w_c('<input type="hidden" name="act" value="special">');
    w_c('</form>');
    p_c();
};

//##########----------syn_system_end----------##########

function arm_select(a1) {
    w_c('<form method="post" target="mission">');
    arm_link(a1);
    w_c('</form>');
    w_c('<div class="font-size-16 text-white text-center">请选择部位</div>');
    p_c();
};

/**
 * 装备分类
 * @param a1
 * @param total
 * @param page
 * @param limit
 */
function arm_link(a1, total, page, limit) {
    w_c(`<div class="mb-10">${arm_return_menu(a1)}</div>`);
    //分页
    // p_nc();
};

function arm_return_menu(a1) {
    return `
<a class="font-size-14" href="javascript:parent.act_click('arm','view',0)" target="mission">武器</a> 
<a class="font-size-14" href="javascript:parent.act_click('arm','view',1)" target="mission">头部</a> 
<a class="font-size-14" href="javascript:parent.act_click('arm','view',2)" target="mission">身体</a>
 <a class="font-size-14" href="javascript:parent.act_click('arm','view',3)" target="mission">手部</a>
  <a class="font-size-14" href="javascript:parent.act_click('arm','view',4)" target="mission">脚部</a>  |
 <a class="font-size-14" href="javascript:parent.act_click('arm','view',5)" target="mission">道具</a>
<!-- <a class="font-size-14" href="javascript:parent.act_click('arm','view',6)" target="mission">消耗品</a>-->
  <a class="font-size-14" href="javascript:parent.act_click('arm','view',7)" target="mission">魔石</a>
   <a class="font-size-14" href="javascript:parent.act_click('arm','view',8)" target="mission">勋章</a> 
   <a class="font-size-14" href="javascript:parent.act_click('arm','view',9)" target="mission">钥匙</a>
    <a class="font-size-14" href="javascript:parent.act_click('arm','view',10)" target="mission">精炼石</a>`;
};


function bag_up(str, type) {
    arm_select();
    var temp = "";
    switch (type) {
        case 1:
            temp = "道具栏";
            break;
        case 2:
            temp = "仓库";
            break;
    }
    temp = '<b>' + temp + '增加 ' + str + ' 格</b>';
    wog_message_box(temp, 0, 2);
};